@extends('web.common.main')
@section('container')
<div class="v3-contain">
    <div class="v3-list j_tab">
        @include('web.common.bread_menu_tab')
        <div class="v3-filter">
            <dl>
                <dt>名称</dt>
                <dd>
                    <input class="ipt j_filterTitle" type="text">
                    <button class="btn j_submitSearch2" type="button">搜索</button>
                </dd>
            </dl>
            <dl>
                <dt>地区</dt>
                <dd class="j_extendCats">
                    <input type="hidden" class="j_filterArea" value="-1">
                    <a data-id="-1" class="sel"><i></i>全部</a>
                    @forelse($areaList as $key=>$value)
                    <a data-id="{{$value['id']}}"><i></i>{{$value['name']}}</a>
                    @empty
                    @endforelse
                </dd>
            </dl>
            <dl>
                <dt>领域</dt>
                <dd class="j_extendCats">
                    <input type="hidden" class="j_filterDomain" value="-1">
                    <a data-id="-1" class="sel"><i></i>全部</a>
                    @forelse($domainList as $key=>$value)
                    <a data-id="{{$value['id']}}"><i></i>{{$value['name']}}</a>
                    @empty
                    @endforelse
                </dd>
            </dl>
            <dl>
                <dt>提供的技术路径</dt>
                <dd class="j_extendCats">
                    <input type="hidden" class="j_filterTechRoute" value="-1">
                    <a data-id="-1" class="sel"><i></i>全部</a>
                    @forelse($techRouteList as $key=>$value)
                    <a data-id="{{$value['id']}}" domain-list="{{$value['domain']}}"><i></i>{{$value['name']}}</a>
                    @empty
                    @endforelse
                </dd>
            </dl>
            <div class="btns">
                您是服务商？这里没有找到您的信息，点此 <a href="/company_login" class="btn">登记我的企业</a>
            </div>
        </div>
        <div class="v3-filter_title">以下是搜索结果</div>
        <div class="v3-filter_result">
            <table class="v3-table v3-table_list">
                <thead>
                <tr>
                    <th width="200">名称</th>
                    <th width="120">地区</th>
                    <th width="160">领域</th>
                    <th>提供的技术路径</th>
                    <th>服务能力</th>
                    <th width="160">&nbsp;</th>
                </tr>
                </thead>
                <tbody class="j_dataList">
                @include('web.market.list.servicer')
                </tbody>
            </table>
            <input id="j_pageNo" type="hidden" value="1" data-tot="{{$pageCount}}" data-url="/market_coo/servicer">
            {{-- <a class="v3-load_more j_loadMore">加载更多...</a> --}}
        </div>
        <div id="page"></div>
    </div>
</div>
@endsection

@section('css')
<link rel="stylesheet" href="{{env('SOURCE_PATH')}}css/jquery.page.css">
@endsection
@section('script')
<script type="text/javascript" src="{{env('SOURCE_PATH')}}js/jquery.page.js"></script>

<script>
    (function ($) {
        $(function () {
            $("#page").Page({
              totalPages: {{$pageCount}},//分页总数
              liNums: 7,//分页的数字按钮数(建议取奇数)
              activeClass: 'activP', //active 类样式定义
              callBack : function(page){
                    //console.log(page)
                    lastPostFunc2(page);
              }
          });

            $.More();

            $('.v3-filter dl a:not(".more")').click(function () {
                var $t = $(this);
                var $p = $t.parent();
                $p.find('a.sel').removeClass('sel');
                $t.addClass('sel');
            });

            //领域切换路径
            $('.j_extendCats').eq(1).find('a[data-id]').on('click', function () {
                var $t = $(this), val = $t.attr('data-id');
                var $a = $('.j_extendCats').eq(2).find('a'), i = 1, len = $a.length;
                $a.removeClass('sel').eq(0).addClass('sel');
                if (val == '-1') {
                    $a.css('display', 'block');
                    $.More();
                } else {
                    $a.css('display', 'none');
                    $a.eq(0).css('display', 'block');
                    for (; i < len; i++) {
                        if (($a.eq(i).attr('domain-list') + '').indexOf(',' + val + ',') != -1) {
                            $a.eq(i).css('display', 'block');
                        }
                    }
                    $.More();
                }
            });

            //搜索
            $('.j_submitSearch').on('click', function () {
                $(".j_dataList").html('');
                var $page = $('#j_pageNo');
                $page.val(0);
                var $filter = $('.j_extendCats');
                $('.j_filterArea').val($filter.eq(0).find('a.sel').attr('data-id'));
                $('.j_filterDomain').val($filter.eq(1).find('a.sel').attr('data-id'));
                $('.j_filterTechRoute').val($filter.eq(2).find('a.sel').attr('data-id'));
                if ($('.j_loadMore').length == 0) {
                    $('<a class="v3-load_more j_loadMore">加载更多...</a>').insertAfter($page);
                }
                $(window).scroll();
            });

            $(".j_submitSearch2").on('click',function(){
                var $filter = $('.j_extendCats');
                $('.j_filterArea').val($filter.eq(0).find('a.sel').attr('data-id'));
                $('.j_filterDomain').val($filter.eq(1).find('a.sel').attr('data-id'));
                $('.j_filterTechRoute').val($filter.eq(2).find('a.sel').attr('data-id'));

                lastPostFunc2(0);

                $("#page").Page({
                  totalPages: $("#ajaxPageCount").val(),//分页总数
                  liNums: 7,//分页的数字按钮数(建议取奇数)
                  activeClass: 'activP', //active 类样式定义
                  callBack : function(page){
                        //console.log(page)
                        lastPostFunc2(page);
                  }
              });
            });

            //联系我们
            $('.j_dataList').on('click', '.j_showContact', function (e) {
                e.stopPropagation();
                var $t = $(this);
                var y = $t.offset().top + parseInt($t.height());
                var x = $t.offset().left;
                if ($('#j_alert').length > 0) {
                    $('#j_alert').remove();
                }
                $('<div id="j_alert" class="alert alert-success" style="top:' + y + 'px;left:' + x + 'px;">联系电话：<br>0571-83530377</div>').appendTo($('body'));
            });
            $('body').on('click', function () {
                if ($('#j_alert').length > 0) {
                    $('#j_alert').remove();
                }
            });
        });
    })(jQuery);
</script>
@endsection
